package com.mydemo.design_pattern.action_type.state_pattern;

import org.apache.commons.lang.StringUtils;

/**
 * <p></p >
 *
 * @author liming1
 * @version $Id: Context, v1.0 2019-09-24 9:57 liming1 Exp $
 */
public class Context {

    private String msg = StringUtils.EMPTY;

    private boolean isEnd = true;

    private State state;

    // 定义Context的初始状态
    public Context(State state) {
        this.state = state;
    }

    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }

    public boolean isEnd() {
        return isEnd;
    }

    public void setEnd(boolean end) {
        isEnd = end;
    }

    public void request() {
        state.handler(this);
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
